<template>
  <FormView
    v-model="entity"
    :title="!entity.id ? '新建工作事项催办表' : '修改工作事项催办表'"
    :toolbar-attrs="{ buttons: ['back', 'save', 'cancel'] }"
    :toolbar-listeners="{ save: persist }">
    <template #toolbar-right>
    </template>
    <FormHolder ref="form" label-width="110px" :model="entity">
      <FormItemGroup block-title="基本信息">
        <FormInput
          v-model="entity.description"
          prop="description"
          label="催办说明"
          :span="12"
          max-length="2000"/>
        <FormInput
          v-model="entity.sourceId"
          prop="sourceId"
          label="源业务ID"
          :span="12"/>
        <FormInput
          v-model="entity.sourceType"
          prop="sourceType"
          label="源业务类型"
          :span="12"
          max-length="255"/>
        <FormInput
          v-model="entity.status"
          prop="status"
          label="催办反馈状态：0:未反馈，1：已反馈"
          :span="12"/>
        <FormInput
          v-model="entity.feedbackDescription"
          prop="feedbackDescription"
          label="催办反馈说明"
          :span="12"
          max-length="2000"/>
        <FormDatePicker
          v-model="entity.feedbackTime"
          format="yyyy-MM-dd hh:mm:ss"
          value-format="yyyy-MM-dd hh:mm:ss"
          label="反馈时间"
          prop="feedbackTime"/>
      </FormItemGroup>
      <FormItemGroup :gutter="0" block-title="附件信息">
        <UploadPage
          v-if="entity.unid"
          ref="UploadPage"
          style="padding: 0;"
          :unique-code="entity.unid"
          model="purchaseOrder"
          classify="purchaseOrder"/>
      </FormItemGroup>
    </FormHolder>
  </FormView>
</template>

<script>
  import { load, create, save, update } from '@/api/workItem/urgent'
  import form from '@/vue/mixin/form'
  import { fetchTree } from '@/api/admin/dept'
  import UploadPage from '@/components/upload/UploadPage'

  export default {
    name: 'UrgentForm',
    relativeViewId: 'urgent',
    components: { UploadPage },
    mixins: [form],
    data() {
      return {
        entity: {
          id: '',
          unid: '',
          createId: '',
          createBy: '',
          createTime: '',
          deptId: '',
          deptFullname: '',
          updateBy: '',
          updateTime: '',
          description: '',
          sourceId: '',
          sourceType: '',
          status: '',
          feedbackDescription: '',
          feedbackTime: ''
        },
        deptTreeList: []
      }
    },
    created() {
      this.init()
    },
    methods: {
      create,
      load,
      save,
      update,
      async init() {
        const res = await fetchTree()
        this.deptTreeList = res.data.data
      }
    }
  }
</script>
